package com.salton123.qa.demo;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;

/**
 * User: newSalton@outlook.com
 * Date: 2018/12/6 11:08 AM
 * ModifyTime: 11:08 AM
 * Description:
 */
public class TestDialogLeakAty extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // setContentView(R.layout.activity_main);
        //
        AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(false)
            .setPositiveButton("confirm", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    login();
                }
            });
        builder.create().show();

        // f(android.R.id.content).postDelayed(
        //         new Runnable() {
        //             @Override
        //             public void run() {
        //                 finish();
        //             }
        //         }, 3000
        // );
    }

    private void login() {
        Toast.makeText(getApplicationContext(), "hello", Toast.LENGTH_LONG).show();
        try {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }).start();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
